/**
*@description 用户画像》自然人属性》渠道来源
*@author yhw
*/
import React, { Component, PropTypes } from 'react';
import { routerRedux } from 'dva/router';
import { connect } from 'dva';
import MainLayout from '../components/MainLayout/MainLayout';
import PieSimple from '../components/Persons/PieSimple';
import Bar2 from '../components/Persons/Bar2';
import TableList from '../components/TableList';
import {Card, Icon, Tooltip, Row, Col} from 'antd';

const tips1 = (<div>按活动&nbsp;
  <Tooltip placement="right" title="渠道来源-按活动是指用户参加的活动来源标签特征">
          <Icon type="question-circle-o" />
  </Tooltip></div>),
tips2 = (<div>按渠道&nbsp;
  <Tooltip placement="right" title="渠道来源-按平台是指用户平台来源标签特征">
          <Icon type="question-circle-o" />
  </Tooltip></div>);

class PersonsSource extends Component {
  constructor(props) {
      super(props);
  }
  // 获取数据
  fetchData(type, search){
    this.props.dispatch({
            type: type,
            search: search
    })
  };
  initData(){
    this.fetchData('PersonsSource/sourceQuery','');
    this.fetchData('PersonsSource/activityQuery','');
  };
  componentWillMount() {
    this.initData();
  };
  render(){
  return (
    <MainLayout>
        <Row gutter={16} style={{marginTop:"29px"}}>
              <Col className="gutter-row" span={16}>
              <div className="gutter-box">
                    <Card title={tips1}>
                      <Bar2 seriesName="按活动" data={this.props.PersonsSource.activityData} loading={this.props.PersonsSource.activityLoading} width={"100%"} height={300} />
                    </Card>
                    <Card title={tips2}>
                      <PieSimple data={this.props.PersonsSource.sourceData} labelPosition={true} loading={this.props.PersonsSource.sourceLoading} seriesName="按渠道" width={"100%"} height={300} />
                    </Card>
              </div>
              </Col>
              <Col className="gutter-row" span={8}><div className="gutter-box"><TableList pageSize={18} /></div></Col>
        </Row>
    </MainLayout>
  );
  }
};

PersonsSource.propTypes = {
};

function mapStateToProps({ PersonsSource }) {
  return {
    PersonsSource: {...PersonsSource},
  };
}

export default connect(mapStateToProps)(PersonsSource);